<script setup>
import { timeDataStore, addressStore } from '@/stores'
import {
  orderDatas,
  transports,
  totalDatas,
  updateOrderData,
  updateTransportData,
  updateTotalData,
} from '@/data/timeData'
import {
  orderDataService,
  transportDataService,
  totalDataService,
} from '@/api/car'
import { ref, onMounted } from 'vue'

const store = timeDataStore()
const address = addressStore()
const currentTime = ref(new Date().toLocaleString())

//调用函数
onMounted(() => {
  store.fetchorderData()
  store.fetchtransportData()
  store.fetchtotalData()
})
</script>
<template>
  <div class="time">
    <p>实时线路数据</p>
  </div>
  <div style="display: flex">
    <TimeData :data="store.orderData" title="订单池"></TimeData>
    <TimeData :data="store.transportData" title="当前运力"></TimeData>
    <div class="totalData">
      <div class="title">
        <p>实时总览数据</p>
        <div class="time">统计截止时间：{{ currentTime }}</div>
      </div>
      <div class="data">
        <div
          class="shuju"
          v-for="(item, index) in store.totalData"
          :key="index"
        >
          <div class="project">{{ item.project }}</div>
          <span class="num">{{ item.num }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.time {
  height: 46px;
  line-height: 46px;
  margin-left: 20px;
  border-bottom: 1px solid #e4e7ed;
}
.totalData {
  width: 1025px;
  height: auto;
  border: 1px solid #e4e7ed;
  border-radius: 10px;
  margin: 20px 0 0 20px;
  .title {
    border-bottom: 1px solid #e4e7ed;
    width: auto;
    height: auto;
    display: flex;
    justify-content: space-between;
    p {
      margin: auto 0 auto 25px;
      height: 46px;
      line-height: 46px;
    }
    .time {
      height: 46px;
      line-height: 46px;
      margin-right: 25px;
    }
  }
  .data {
    display: flex;
    flex-wrap: wrap;
    .shuju {
      text-align: center;
      .project {
        margin: 18px 30px 10px 30px;
      }
      .num {
        margin: auto;
      }
    }
  }
}
</style>
